<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="test"></div>
<div id="test2"></div>
<script type="text/javascript" src="../js/react.development.js"></script>
<script type="text/javascript" src="../js/react-dom.development.js"></script>
<script type="text/javascript" src="../js/babel.min.js"></script>
<script type="text/javascript" src="../js/prop-types.js"></script>
<script type="text/babel">
  class Person extends React.Component{
    constructor(props) {
      console.log(props)
      super(props);
    }
    // 对标签属性进行类型，必要性的限制
    static propTypes={
      name:PropTypes.string.isRequired,
      sex:PropTypes.string,
      age:PropTypes.number
    }
    // 指定默认标签属性
    static defaultProps={
      sex:'不男不女',
      age:18
    }
    render(){
      const {name,age,sex} = this.props
      // this.props.name = 'xqz' //报错，因为props是只读的
      return (
        <ul>
          <li>姓名:{name}</li>
          <li>性别:{age+1}</li>
          <li>年龄:{sex}</li>
        </ul>
      )
    }
  }

  ReactDOM.render(<Person name="xqz" age={19} sex="man"/>,document.getElementById('test2'))

</script>
</body>
</html>
